package com.qyhl.module_practice.activity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.gyf.immersionbar.ImmersionBar;
import com.makeramen.roundedimageview.RoundedImageView;
import com.qyhl.module_practice.R;
import com.qyhl.module_practice.R2;
import com.qyhl.module_practice.substreet.detail.StreetDetailActivity;
import com.qyhl.module_practice.team.detail.PracticeTeamDetailActivity;
import com.qyhl.webtv.basiclib.base.BaseFragment;
import com.qyhl.webtv.basiclib.utils.DateUtils;
import com.qyhl.webtv.basiclib.utils.NetUtil;
import com.qyhl.webtv.basiclib.utils.StringUtils;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.constant.ARouterPathConstant;
import com.qyhl.webtv.commonlib.entity.civilized.PracticeAcitivityBean;
import com.qyhl.webtv.commonlib.utils.eventbus.BusFactory;
import com.qyhl.webtv.commonlib.utils.eventbus.Event;
import com.qyhl.webtv.commonlib.utils.router.RouterManager;
import com.scwang.smartrefresh.header.MaterialHeader;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.weavey.loading.lib.LoadingLayout;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.MultiItemTypeAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;
import com.zhy.adapter.recyclerview.wrapper.HeaderAndFooterWrapper;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class PracticeActFragment extends BaseFragment implements PracticeActContract.PracticeActView {
    @BindView(R2.id.recycle_view)
    RecyclerView recycleView;
    @BindView(R2.id.refresh)
    SmartRefreshLayout refresh;
    @BindView(R2.id.load_mask)
    LoadingLayout loadMask;
    @BindView(R2.id.search_layout)
    RelativeLayout searchLayout;
    @BindView(R2.id.spinner)
    Spinner spinner;
    @BindView(R2.id.search_txt)
    EditText searchTxt;
    @BindView(R2.id.search_btn)
    TextView searchBtn;
    @BindView(R2.id.search_txt_delete)
    ImageButton searchDel;

    private String streetId;

    private int page = 1;

    private String keyword = "";

    private String status = "ALL";

    private CommonAdapter commonAdapter;

    private HeaderAndFooterWrapper<PracticeAcitivityBean> headerAndFooterWrapper;

    private List<PracticeAcitivityBean> mDataList = new ArrayList<>();

    private PracticeActPresenter mPresenter;

    public void setStreetId(String streetId) {
        this.streetId = streetId;
    }

    private String userName = CommonUtils.getInstance().getUserName();

    private String instId;

    public void setInstId(String instId) {
        this.instId = instId;
    }

    private int fromType = 0;//0实践列表   1 街道  2服务队

    private float startY, offsetY;

    private String type;

    public void setType(String type) {
        this.type = type;
    }

    public void setFromType(int fromType) {
        this.fromType = fromType;
    }

    public static PracticeActFragment newInstance(String streetId, int fromType, String instId, String type) {
        PracticeActFragment fragment = new PracticeActFragment();
        fragment.setStreetId(streetId);
        fragment.setFromType(fromType);
        fragment.setInstId(instId);
        fragment.setType(type);
        return fragment;
    }


    @Override
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this)
                .statusBarDarkFont(true, 0.2f)
                .statusBarColor(R.color.white)
                .fitsSystemWindows(true)
                .init();
    }


    @Override
    protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.practice_fragment_practice_activity, null);
    }


    @Override
    protected void create() {
        BusFactory.getBus().register(this);
        mPresenter = new PracticeActPresenter(this);
        loadData();
    }


    /**
     * 加载数据
     */
    private void loadData() {
        //下拉刷新
        initView();
        setListener();
        switch (fromType) {
            case 0:
                mPresenter.getList(page + "", status, keyword, type);
                break;
            case 1:
                mPresenter.getStreetList(streetId, page + "", userName);
                break;
            case 2:
                mPresenter.getOrgList(streetId, page + "");
                break;
            default:
                break;
        }
    }


    private void initView() {
        loadMask.setStatus(LoadingLayout.Loading);

        refresh.setEnableLoadMore(true);
        refresh.setNestedScrollingEnabled(true);
        refresh.setRefreshHeader(new MaterialHeader(getContext()));
        refresh.setRefreshFooter(new ClassicsFooter(getContext()));

        ArrayAdapter adapter = ArrayAdapter.createFromResource(getContext(), R.array.practice_practice_search, R.layout.practice_spinner_search_layout);
        adapter.setDropDownViewResource(R.layout.practice_spinner_item_layout);
        spinner.setPopupBackgroundResource(R.drawable.practice_spinner_search_bg);
        spinner.setDropDownVerticalOffset(StringUtils.dip2px(getContext(), 25));
        spinner.setBackgroundColor(0x0);
        spinner.setAdapter(adapter);

        //设置布局管理器
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recycleView.setLayoutManager(linearLayoutManager);
        int layout;

        switch (fromType) {
            case 0:
                searchLayout.setVisibility(View.VISIBLE);
                layout = R.layout.practice_item_activity;
                break;
            case 1:
                searchLayout.setVisibility(View.GONE);
                layout = R.layout.practice_item_act;
                break;
            case 2:
                searchLayout.setVisibility(View.GONE);
                layout = R.layout.practice_item_act;
                break;
            case 3:
                searchLayout.setVisibility(View.GONE);
                layout = R.layout.practice_item_activity;
                break;
            default:
                searchLayout.setVisibility(View.GONE);
                layout = R.layout.practice_item_activity;
                break;
        }
        commonAdapter = new CommonAdapter<PracticeAcitivityBean>(getContext(), layout, mDataList) {
            @SuppressLint("SetTextI18n")
            @Override
            protected void convert(ViewHolder holder, final PracticeAcitivityBean bean, int position) {
                RoundedImageView cover = holder.getView(R.id.cover);
                Glide.with(getContext().getApplicationContext())
                        .load(bean.getLogo())
                        .apply(new RequestOptions().error(R.drawable.cover_large_default).placeholder(R.drawable.cover_large_default))
                        .into(cover);

                TextView title = holder.getView(R.id.title);
                TextView address = holder.getView(R.id.address);
                TextView endTime = holder.getView(R.id.end_time);
                TextView serviceTime = holder.getView(R.id.service_time);
                TextView loveCounts = holder.getView(R.id.love_counts);
                TextView personTxt = holder.getView(R.id.person_txt);
                TextView personNum = holder.getView(R.id.person_num);
                TextView host = holder.getView(R.id.host);
                TextView expectTime = holder.getView(R.id.expect_time);

                ImageView status = holder.getView(R.id.status);

                TextView tag = holder.getView(R.id.tag);
                if (bean.getTypes() != null && bean.getTypes().size() > 0) {
                    tag.setVisibility(View.VISIBLE);
                    StringBuilder stringBuilder = new StringBuilder();
                    for (int i = 0; i < bean.getTypes().size(); i++) {
                        if (i == 0) {
                            stringBuilder.append(bean.getTypes().get(i).getName());
                        } else {
                            stringBuilder.append("、").append(bean.getTypes().get(i).getName());
                        }
                    }
                    holder.setText(R.id.tag, stringBuilder.toString());
                } else {
                    tag.setVisibility(View.INVISIBLE);
                }
                if (bean.getSigninType() == 0) {
                    holder.setText(R.id.sign_type, "定位签到");
                } else {
                    holder.setText(R.id.sign_type, "扫码签到");
                }

                title.setText(bean.getName());
                address.setText("地址：" + bean.getAddress());
                endTime.setText("招募截止：" + DateUtils.practiceSignFormat(bean.getEndTime()));

                serviceTime.setText("服务时间：" + DateUtils.practiceServiceFormat(StringUtils.isEmpty(bean.getRegistrationStart()) ? "" : bean.getRegistrationStart()) + " -" + DateUtils.practiceServiceFormat(StringUtils.isEmpty(bean.getRegistrationDeadline()) ? "" : bean.getRegistrationDeadline()));
                if(bean.getActSignType()==1){
                    expectTime.setVisibility(View.GONE);
                }else{
                    expectTime.setVisibility(View.VISIBLE);
                    expectTime.setText("预计服务时长：" + bean.getServiceTime() + "小时");
                }

                loveCounts.setText(bean.getScore() + "分");
                personNum.setText(bean.getVolunteerNum() + "/" + bean.getQuantityDemanded());
                if ("1".equals(type)) {
                    host.setText("爱心对接：" + bean.getSource());
                } else {
                    host.setText("主办单位：" + bean.getSource());
                }
                switch (bean.getStatus()) {
                    case "RECRUIT":
                        title.setTextColor(ContextCompat.getColor(getContext(), R.color.global_black_lv1));
                        address.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        endTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        serviceTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personTxt.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personNum.setTextColor(ContextCompat.getColor(getContext(), R.color.global_base));
                        tag.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        host.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        expectTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        Glide.with(getContext().getApplicationContext())
                                .load(R.drawable.practice_act_join_icon)
                                .into(status);
                        break;
                    case "SERVICE":
                        title.setTextColor(ContextCompat.getColor(getContext(), R.color.global_black_lv1));
                        address.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        endTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        serviceTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personTxt.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personNum.setTextColor(ContextCompat.getColor(getContext(), R.color.global_base));
                        tag.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        host.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        expectTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        Glide.with(getContext().getApplicationContext())
                                .load(R.drawable.practice_act_service_icon)
                                .into(status);
                        break;
                    case "BEGINNING":
                        title.setTextColor(ContextCompat.getColor(getContext(), R.color.global_black_lv1));
                        address.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        endTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        serviceTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personTxt.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personNum.setTextColor(ContextCompat.getColor(getContext(), R.color.global_base));
                        tag.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        host.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        expectTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        Glide.with(getContext().getApplicationContext())
                                .load(R.drawable.practice_act_on_icon)
                                .into(status);
                        break;
                    case "END":
                        title.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_global_black_lv1_60per));
                        address.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color_60per));
                        endTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color_60per));
                        serviceTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color_60per));
                        personTxt.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color_60per));
                        personNum.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color_60per));
                        tag.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color_60per));
                        host.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color_60per));
                        expectTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color_60per));
                        Glide.with(getContext().getApplicationContext())
                                .load(R.drawable.practice_act_end_icon)
                                .into(status);
                        break;
                    case "NOT_BEGIN":
                        title.setTextColor(ContextCompat.getColor(getContext(), R.color.global_black_lv1));
                        address.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        endTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        serviceTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personTxt.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personNum.setTextColor(ContextCompat.getColor(getContext(), R.color.global_base));
                        tag.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        host.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        expectTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        Glide.with(getContext().getApplicationContext())
                                .load(R.drawable.practice_act_forecast_icon)
                                .into(status);
                        break;
                    default:
                        title.setTextColor(ContextCompat.getColor(getContext(), R.color.global_black_lv1));
                        address.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        endTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        serviceTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personTxt.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        personNum.setTextColor(ContextCompat.getColor(getContext(), R.color.global_base));
                        tag.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        host.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        expectTime.setTextColor(ContextCompat.getColor(getContext(), R.color.practice_normal_color));
                        Glide.with(getContext().getApplicationContext())
                                .load(R.drawable.practice_act_on_icon)
                                .into(status);
                        break;
                }
            }
        };

//        if (fromType == 0) {
//            View headView = LayoutInflater.from(getContext()).inflate(R.layout.layout_practice_act_headview, null);
//            ResizableImageView headCover = headView.findViewById(R.id.head_cover);
//            headCover.setImageResource(R.drawable.practice_act_head_cover_icon);
//            headerAndFooterWrapper = new HeaderAndFooterWrapper<>(commonAdapter);
//            headerAndFooterWrapper.addHeaderView(headView);
//            recycleView.setAdapter(headerAndFooterWrapper);
//        } else {
        recycleView.setAdapter(commonAdapter);
//        }


    }

    @Override
    @SuppressLint("ClickableViewAccessibility")
    protected void setListener() {
        loadMask.setOnReloadListener(v -> {
            loadMask.setReloadButtonText("加载中...");
            page = 1;
            switch (fromType) {
                case 0:
                    mPresenter.getList(page + "", status, keyword, type);
                    break;
                case 1:
                    mPresenter.getStreetList(streetId, page + "", userName);
                    break;
                case 2:
                    mPresenter.getOrgList(streetId, page + "");
                    break;
                default:
                    break;
            }
        });

        refresh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                loadMask.setReloadButtonText("加载中...");
                page = 1;
                switch (fromType) {
                    case 0:
                        mPresenter.getList(page + "", status, keyword, type);
                        break;
                    case 1:
                        mPresenter.getStreetList(streetId, page + "", userName);
                        break;
                    case 2:
                        mPresenter.getOrgList(streetId, page + "");
                        break;
                    default:
                        break;
                }
            }
        });

        refresh.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                switch (fromType) {
                    case 0:
                        mPresenter.getList(page + "", status, keyword, type);
                        break;
                    case 1:
                        mPresenter.getStreetList(streetId, page + "", userName);
                        break;
                    case 2:
                        mPresenter.getOrgList(streetId, page + "");
                        break;
                    default:
                        break;
                }
            }
        });

        commonAdapter.setOnItemClickListener(new MultiItemTypeAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
                int mPostion;
                mPostion = position;

                Bundle bundle = new Bundle();
                bundle.putString("id", mDataList.get(mPostion).getId() + "");
                bundle.putString("userName", userName);
                bundle.putString("instId", instId);
                bundle.putString("userName", userName);
                bundle.putString("title", mDataList.get(mPostion).getName());
                RouterManager.router(ARouterPathConstant.PRACTICE_ACT_DETAIL, bundle);

            }

            @Override
            public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) {
                return false;
            }
        });

        loadMask.setOnTouchListener((v, event) -> {
            if (loadMask.getStatus() != LoadingLayout.Success) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        startY = event.getY();
                        break;
                    case MotionEvent.ACTION_UP:
                        offsetY = event.getY() - startY;
                        if (loadMask.getStatus() != LoadingLayout.Success) {
                            if (offsetY > 30) {
                                if (getActivity() instanceof StreetDetailActivity) {
                                    StreetDetailActivity activity = (StreetDetailActivity) getActivity();
                                    activity.collapsed();
                                } else if (getActivity() instanceof PracticeTeamDetailActivity) {
                                    PracticeTeamDetailActivity activity = (PracticeTeamDetailActivity) getActivity();
                                    activity.collapsed();
                                }
                            } else if (offsetY < -30) {
                                if (getActivity() instanceof StreetDetailActivity) {
                                    StreetDetailActivity activity = (StreetDetailActivity) getActivity();
                                    activity.expanded();
                                } else if (getActivity() instanceof PracticeTeamDetailActivity) {
                                    PracticeTeamDetailActivity activity = (PracticeTeamDetailActivity) getActivity();
                                    activity.expanded();
                                }
                            }

                        }
                        break;
                    case MotionEvent.ACTION_MOVE:
                        break;
                    default:
                        break;
                }
                return true;
            } else {
                return false;
            }
        });

        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                page = 1;
                switch (position) {
                    case 0:
                        status = "ALL";
                        break;
                    case 1:
                        status = "RECRUIT";
                        break;
                    case 2:
                        status = "SERVICE";
                        break;
                    case 3:
                        status = "END";
                        break;
                    default:
                        status = "ALL";
                        break;
                }
                mPresenter.getList(page + "", status, keyword, type);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        searchTxt.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                keyword = s.toString();
                if (StringUtils.isNotEmpty(s.toString()) && s.toString().trim().length() > 0) {
                    searchBtn.setText("搜索");
                    searchDel.setVisibility(View.VISIBLE);
                } else {
                    searchBtn.setText("取消");
                    searchDel.setVisibility(View.GONE);
                }
            }
        });

        searchTxt.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {//按下搜索
                    keyword = searchTxt.getText().toString();
                    mPresenter.getList(page + "", status, keyword, type);
                    hideInput();
                }
                return false;//返回true，保留软键盘。false，隐藏软键盘
            }

        });
    }

    @Override
    protected void onFirstVisible() {

    }

    @Override
    protected void onVisible() {

    }

    @Override
    protected void onHide() {

    }

    @Override
    public void setList(List<PracticeAcitivityBean> beanList, boolean isMore) {
        loadMask.setReloadButtonText("点击重试~");
        loadMask.setStatus(LoadingLayout.Success);
        page++;
        if (isMore) {
            refresh.finishLoadMore();
        } else {
            refresh.finishRefresh();
            mDataList.clear();
        }
        mDataList.addAll(beanList);
//        if (fromType == 0) {
//            headerAndFooterWrapper.notifyDataSetChanged();
//        } else {
        commonAdapter.notifyDataSetChanged();
//        }

    }

    @Override
    public void setError(String msg, boolean isMore) {
        loadMask.setReloadButtonText("点击重试~");
        if (isMore) {
            refresh.finishLoadMore();
        } else {
            refresh.finishRefresh();
            loadMask.setStatus(LoadingLayout.Error);
            if (!NetUtil.isNetworkAvalible(getContext())) {
                loadMask.setErrorImage(R.drawable.error_network);
                loadMask.setErrorText("网络异常，请检查您的网络！");
            } else if (msg.contains("暂无")) {
                loadMask.setErrorImage(R.drawable.empty_content);
                loadMask.setErrorText(msg);
            } else {
                loadMask.setErrorImage(R.drawable.error_content);
                loadMask.setErrorText(msg);
            }
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        BusFactory.getBus().unregister(this);
    }


    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getMessage(Event.LoginMessage event) {
        if (event != null) {
            page = 1;
            switch (fromType) {
                case 0:
                    mPresenter.getList(page + "", status, keyword, type);
                    break;
                case 1:
                    mPresenter.getStreetList(streetId, page + "", userName);
                    break;
                case 2:
                    mPresenter.getOrgList(streetId, page + "");
                    break;
            }
        }
    }


    @OnClick({R2.id.search_btn, R2.id.search_txt_delete})
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.search_btn) {
            if (searchBtn.getText().toString().equals("搜索")) {
                hideInput();
                if (StringUtils.isNotEmpty(keyword)) {
                    page = 1;
                    mPresenter.getList(page + "", status, keyword, type);
                } else {
                    showToast("搜索内容不能为空！", 4);
                }
            } else {
                page = 1;
                mPresenter.getList(page + "", status, keyword, type);
            }
        } else if (id == R.id.search_txt_delete) {
            searchTxt.setText("");
        }
    }
}
